/**
 * @file AsignarResultadoPruebaBioquimicaGeneral.java
 * @brief Interfaz asigna los resultados de la prueba de bioquimica general
 *
 * Copyright (C)  - May [2011]
 *
 * @author Carlos Castilla Ruiz
 * @version 01.00
 *
 */

package interfaces;

import clinica.ClinicaView;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.JPanel;
import org.jdesktop.application.Action;
import clinica.Interfaces;
import GestorPruebas.*;
import Controlador.Controlador;
import java.io.IOException;
import java.sql.SQLException;
import GestorUsuarios.Paciente;


public class AsignarResultadoPruebaBioquimicaGeneral extends javax.swing.JPanel {

    private ClinicaView app;
    Interfaces _anterior;
    private BioquimicaGeneral prueba;
    Pattern p = Pattern.compile("[0-9]+(\\.[0-9]+)?");
    Matcher m;
    boolean hay_errores;

    public AsignarResultadoPruebaBioquimicaGeneral(ClinicaView a) {
        initComponents();
        app = a;
    }


    public void limpiaEntradas(Prueba p,Interfaces ant) throws java.security.NoSuchAlgorithmException,java.lang.ClassNotFoundException,java.io.IOException,java.sql.SQLException{
       _anterior=ant;
       prueba= (BioquimicaGeneral)p;

       acido_urico.setText("");
       creatinina.setText("");
       urea.setText("");
       glucosa.setText("");
       colesterol.setText("");
       colesterol_hdl.setText("");
       colesterol_ldl.setText("");
       trigliceridos.setText("");
       bilirrubina_total.setText("");
       g_glutamiltransferasa.setText("");
       aspartato_transaminasa.setText("");
       almina_transaminasa.setText("");

       Paciente pac = (Paciente) Paciente.get(prueba.getIdPaciente());
       informacion_prueba.setText(pac.getNombre()+" "+pac.getApellidos()+", "+prueba.getTipo()+", "+prueba.getFecha());

    }


    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        creatinina = new javax.swing.JTextField();
        urea = new javax.swing.JTextField();
        glucosa = new javax.swing.JTextField();
        colesterol = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        colesterol_hdl = new javax.swing.JTextField();
        colesterol_ldl = new javax.swing.JTextField();
        trigliceridos = new javax.swing.JTextField();
        bilirrubina_total = new javax.swing.JTextField();
        g_glutamiltransferasa = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        acido_urico = new javax.swing.JTextField();
        aspartato_transaminasa = new javax.swing.JTextField();
        almina_transaminasa = new javax.swing.JTextField();
        informacion_prueba = new javax.swing.JTextField();
        jButton2 = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Datos de la prueba", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 18))); // NOI18N
        jPanel1.setName("jPanel1"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance().getContext().getResourceMap(AsignarResultadoPruebaBioquimicaGeneral.class);
        jLabel3.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        jLabel3.setText("Urea");
        jLabel3.setName("jLabel3"); // NOI18N

        jLabel2.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        jLabel2.setText("Creatinina");
        jLabel2.setName("jLabel2"); // NOI18N

        jLabel1.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        jLabel1.setText("Ácido Úrico");
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel4.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        jLabel4.setText("Glucosa");
        jLabel4.setName("jLabel4"); // NOI18N

        jLabel5.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        jLabel5.setText("Colesterol");
        jLabel5.setName("jLabel5"); // NOI18N

        creatinina.setName("creatinina"); // NOI18N

        urea.setName("urea"); // NOI18N

        glucosa.setName("glucosa"); // NOI18N

        colesterol.setName("colesterol"); // NOI18N

        jLabel13.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        jLabel13.setText("Bilirrubina Total");
        jLabel13.setName("jLabel13"); // NOI18N

        jLabel14.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        jLabel14.setText("Colesterol HDL");
        jLabel14.setName("jLabel14"); // NOI18N

        jLabel15.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        jLabel15.setText("Colesterol LDL");
        jLabel15.setName("jLabel15"); // NOI18N

        jLabel16.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        jLabel16.setText("Trigliceridos");
        jLabel16.setName("jLabel16"); // NOI18N

        jLabel17.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        jLabel17.setText("Gamma Glutamiltransferasa");
        jLabel17.setName("jLabel17"); // NOI18N

        colesterol_hdl.setMaximumSize(new java.awt.Dimension(6, 28));
        colesterol_hdl.setMinimumSize(new java.awt.Dimension(6, 28));
        colesterol_hdl.setName("colesterol_hdl"); // NOI18N
        colesterol_hdl.setPreferredSize(new java.awt.Dimension(6, 28));

        colesterol_ldl.setMaximumSize(new java.awt.Dimension(6, 28));
        colesterol_ldl.setMinimumSize(new java.awt.Dimension(6, 28));
        colesterol_ldl.setName("colesterol_ldl"); // NOI18N
        colesterol_ldl.setPreferredSize(new java.awt.Dimension(6, 28));

        trigliceridos.setMaximumSize(new java.awt.Dimension(6, 28));
        trigliceridos.setMinimumSize(new java.awt.Dimension(6, 28));
        trigliceridos.setName("trigliceridos"); // NOI18N
        trigliceridos.setPreferredSize(new java.awt.Dimension(6, 28));

        bilirrubina_total.setMaximumSize(new java.awt.Dimension(6, 28));
        bilirrubina_total.setMinimumSize(new java.awt.Dimension(6, 28));
        bilirrubina_total.setName("bilirrubina_total"); // NOI18N
        bilirrubina_total.setPreferredSize(new java.awt.Dimension(6, 28));

        g_glutamiltransferasa.setMaximumSize(new java.awt.Dimension(6, 28));
        g_glutamiltransferasa.setMinimumSize(new java.awt.Dimension(6, 28));
        g_glutamiltransferasa.setName("g_glutamiltransferasa"); // NOI18N
        g_glutamiltransferasa.setPreferredSize(new java.awt.Dimension(6, 28));

        jLabel6.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        jLabel6.setText("Aspartato Transaminasa");
        jLabel6.setName("jLabel6"); // NOI18N

        jLabel10.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        jLabel10.setText("Alamina Transaminasa");
        jLabel10.setName("jLabel10"); // NOI18N

        acido_urico.setFont(new java.awt.Font("Tahoma 18 Simple", 0, 12));
        acido_urico.setName("acido_urico"); // NOI18N

        aspartato_transaminasa.setFont(new java.awt.Font("Tahoma 18 Simple", 0, 12)); // NOI18N
        aspartato_transaminasa.setName("aspartato_transaminasa"); // NOI18N

        almina_transaminasa.setFont(new java.awt.Font("Tahoma 18 Simple", 0, 12));
        almina_transaminasa.setName("almina_transaminasa"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(47, 47, 47)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel15, javax.swing.GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGap(71, 71, 71))
                        .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel14))
                    .addComponent(jLabel16, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel13, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel17, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE)
                    .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(colesterol_ldl, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .addComponent(glucosa, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .addComponent(creatinina, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .addComponent(colesterol, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .addComponent(urea, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .addComponent(trigliceridos, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .addComponent(colesterol_hdl, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .addComponent(g_glutamiltransferasa, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .addComponent(bilirrubina_total, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .addComponent(acido_urico, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE))
                .addGap(57, 57, 57)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, 221, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(almina_transaminasa, javax.swing.GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 30, Short.MAX_VALUE)
                        .addComponent(aspartato_transaminasa, javax.swing.GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE)))
                .addGap(67, 67, 67))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel1)
                            .addComponent(acido_urico, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(creatinina, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(urea, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addComponent(glucosa, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(colesterol, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(colesterol_hdl, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(colesterol_ldl, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel15))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(trigliceridos, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel16))
                        .addGap(7, 7, 7)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(bilirrubina_total, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel13))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel17)
                            .addComponent(g_glutamiltransferasa, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(aspartato_transaminasa, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel10)
                            .addComponent(almina_transaminasa, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(47, Short.MAX_VALUE))
        );

        informacion_prueba.setFont(resourceMap.getFont("informacion_prueba.font")); // NOI18N
        informacion_prueba.setFocusable(false);
        informacion_prueba.setName("informacion_prueba"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance().getContext().getActionMap(AsignarResultadoPruebaBioquimicaGeneral.class, this);
        jButton2.setAction(actionMap.get("cancelar")); // NOI18N
        jButton2.setIcon(resourceMap.getIcon("jButton2.icon")); // NOI18N
        jButton2.setName("jButton2"); // NOI18N

        jButton1.setAction(actionMap.get("aceptar")); // NOI18N
        jButton1.setFont(resourceMap.getFont("jButton1.font")); // NOI18N
        jButton1.setIcon(resourceMap.getIcon("jButton1.icon")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addComponent(informacion_prueba, javax.swing.GroupLayout.DEFAULT_SIZE, 450, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 143, Short.MAX_VALUE)
                        .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(27, 27, 27)
                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(informacion_prueba, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton2))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    public boolean comprobarFloat(javax.swing.JTextField tf,String d){
        m = p.matcher(tf.getText().toString());
        if (!m.matches()) {
            hay_errores = true;
            app.addError("El "+d+" debe ser una cifra");
            return false;
        }
        return true;
    }


    @Action
    public void aceptar() throws java.text.ParseException,GestorUsuarios.IDException,java.security.NoSuchAlgorithmException,java.sql.SQLException,java.io.IOException,java.lang.ClassNotFoundException {
        app.limpiaErrores();
        hay_errores = false;
        String exito=null;
        float f=0;

        if(acido_urico.getText().equals("")) {
            hay_errores = true;
            app.addError("No se ha introducido el ácido úrico.");
        }else{
            if(comprobarFloat(acido_urico,"ácido úrico")){
                f=Float.parseFloat(acido_urico.getText());
                if(f>0 && f<10000000){
                    prueba.setAcidoUrico(f);
                }else{
                    hay_errores = true;
                    app.addError("Valor incorrecto de el ácido úrico.");
                }
            }
        }
        if(creatinina.getText().equals("")) {
            hay_errores = true;
            app.addError("No se ha introducido la creatinina.");
        }else{
            if(comprobarFloat(creatinina,"creatinina")){
                f=Float.parseFloat(creatinina.getText());
                if(f>0 && f<10000000){
                    prueba.setCreatinina(f);
                }else{
                    hay_errores = true;
                    app.addError("Valor incorrecto de la creatinina.");
                }
            }
        }
        if(urea.getText().equals("")) {
            hay_errores = true;
            app.addError("No se ha introducido la urea.");
        }else{
            if(comprobarFloat(urea,"urea")){
                f=Float.parseFloat(urea.getText());
                if(f>0 && f<10000000){
                    prueba.setUrea(f);
                }else{
                    hay_errores = true;
                    app.addError("Valor incorrecto de urea.");
                }
            }
        }
        if(glucosa.getText().equals("")) {
            hay_errores = true;
            app.addError("No se ha introducido la glucosa.");
        }else{
            if(comprobarFloat(glucosa,"glucosa")){
                f=Float.parseFloat(glucosa.getText());
                if(f>0 && f<10000000){
                    prueba.setGlucosa(f);
                }else{
                    hay_errores = true;
                    app.addError("Valor incorrecto de glucosa.");
                }
            }
        }
        if(colesterol.getText().equals("")) {
            hay_errores = true;
            app.addError("No se ha introducido el colesterol.");
        }else{
            if(comprobarFloat(colesterol,"colesterol")){
                f=Float.parseFloat(colesterol.getText());
                if(f>0 && f<10000000){
                    prueba.setColesterol(f);
                }else{
                    hay_errores = true;
                    app.addError("Valor incorrecto de colesterol.");
                }
            }
        }
        if(colesterol_hdl.getText().equals("")) {
            hay_errores = true;
            app.addError("No se ha introducido el colesterol hdl.");
        }else{
            if(comprobarFloat(colesterol_hdl,"colesterol HDL")){
                f=Float.parseFloat(colesterol_hdl.getText());
                if(f>0 && f<10000000){
                    prueba.setColesterolHDL(f);
                }else{
                    hay_errores = true;
                    app.addError("Valor incorrecto de colesterol hdl.");
                }
            }
        }
        if(colesterol_ldl.getText().equals("")) {
            hay_errores = true;
            app.addError("No se ha introducido el colesterol ldl.");
        }else{
            if(comprobarFloat(colesterol_ldl,"colesterol ldl")){
                f=Float.parseFloat(colesterol_ldl.getText());
                if(f>0 && f<10000000){
                    prueba.setColesterolLDL(f);
                }else{
                    hay_errores = true;
                    app.addError("Valor incorrecto de colesterol ldl.");
                }
            }
        }
        if(trigliceridos.getText().equals("")) {
            hay_errores = true;
            app.addError("No se ha introducido los trigliceridos.");
        }else{
            if(comprobarFloat(trigliceridos,"trigliceridos")){
                f=Float.parseFloat(trigliceridos.getText());
                if(f>0 && f<10000000){
                    prueba.setTrigliceridos(f);
                }else{
                    hay_errores = true;
                    app.addError("Valor incorrecto de trigliceridos.");
                }
            }
        }
        if(bilirrubina_total.getText().equals("")) {
            hay_errores = true;
            app.addError("No se ha introducido la bilirrubina total.");
        }else{
            if(comprobarFloat(bilirrubina_total,"bilirrubina total")){
                f=Float.parseFloat(bilirrubina_total.getText());
                if(f>0 && f<10000000){
                    prueba.setBilirrubinaTotal(f);
                }else{
                    hay_errores = true;
                    app.addError("Valor incorrecto de bilirrubina total.");
                }
            }
        }
        if(g_glutamiltransferasa.getText().equals("")) {
            hay_errores = true;
            app.addError("No se ha introducido la gamma glutamiltransferasa.");
        }else{
            if(comprobarFloat(g_glutamiltransferasa,"gamma glutamlitransferasa")){
                f=Float.parseFloat(g_glutamiltransferasa.getText());
                if(f>0 && f<10000000){
                    prueba.setGammaGlutamiltransferasa(f);
                }else{
                    hay_errores = true;
                    app.addError("Valor incorrecto de gamma glutamiltransferasa.");
                }
            }
        }
        if(aspartato_transaminasa.getText().equals("")) {
            hay_errores = true;
            app.addError("No se ha introducido la aspartato transaminasa.");
        }else{
            if(comprobarFloat(aspartato_transaminasa,"aspartato transaminasa")){
                f=Float.parseFloat(aspartato_transaminasa.getText());
                if(f>0 && f<10000000){
                    prueba.setAspartatoTransaminasa(f);
                }else{
                    hay_errores = true;
                    app.addError("Valor incorrecto de aspartato transaminasa.");
                }
            }
        }
        if(almina_transaminasa.getText().equals("")) {
            hay_errores = true;
            app.addError("No se ha introducido la almina transaminasa.");
        }else{
            if(comprobarFloat(almina_transaminasa,"almina transaminasa")){
                f=Float.parseFloat(almina_transaminasa.getText());
                if(f>0 && f<10000000){
                    prueba.setAlaminaTransaminasa(f);
                }else{
                    hay_errores = true;
                    app.addError("Valor incorrecto de almina transaminasa.");
                }
            }
        }
       

        if(hay_errores==true) {
            app.muestraListaErrores();
        } else {
            EstadoPrueba e=prueba.getEstadoPrueba();
            exito=Controlador.cambiarEstadoPrueba(prueba.getIdPrueba(),e.Realizada);
            if(exito==null) {
                //app.abrirMensajeExito("El estado ha sido modificado correctamente", _anterior);
            } else {
                app.abrirMensajeError(exito,_anterior);
            }
            exito=Controlador.asignarResultados(prueba);
            if(exito==null) {
                app.abrirMensajeExito("Los resultados han sido asignados correctamente", Interfaces.PRINCIPAL_TECNICO);
            } else {
                app.abrirMensajeError(exito,_anterior);
            }

        }
    }

    @Action
    public void cancelar() {
        app.volver(_anterior);
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField acido_urico;
    private javax.swing.JTextField almina_transaminasa;
    private javax.swing.JTextField aspartato_transaminasa;
    private javax.swing.JTextField bilirrubina_total;
    private javax.swing.JTextField colesterol;
    private javax.swing.JTextField colesterol_hdl;
    private javax.swing.JTextField colesterol_ldl;
    private javax.swing.JTextField creatinina;
    private javax.swing.JTextField g_glutamiltransferasa;
    private javax.swing.JTextField glucosa;
    private javax.swing.JTextField informacion_prueba;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField trigliceridos;
    private javax.swing.JTextField urea;
    // End of variables declaration//GEN-END:variables

}
